<?php

class Database
{
	private $server;
	private $database;
	private $username;
	private $password;
	private $db;
	private $query_id;

	private $tables;

	public function Database($aServer,$aDatabase,$aUsername,$aPassword)
	{
		$this->server =  $aServer;
		$this->database = $aDatabase;
		$this->username = $aUsername;
		$this->password = $aPassword;
		
/*		echo $this->server."<br>";
		echo $this->database."<br>";
		echo $this->username."<br>";
		echo $this->password."<br>";
*/				
		try
		{
			$this->db=mysql_connect($this->server, $this->username, $this->password);
			if($this->db && mysql_select_db($this->database,$this->db))
			{
				// success
			}
			else 
			{
			mysql_close($this->db);
			$this__destruct();
			}
		}
		catch(Exception $anException){echo "Database: exception ".$anException;}
	}


	public function Recopy()
		{
			$newDatabase = new Database($this->server,$this->database,$this->username,$this->password);
			return $newDatabase;
		}


	public function ExecuteSQL($sql)
	{
		if($this->db)
		{
			$this->query_id = mysql_query($sql,$this->db);
//			echo $sql." result <br><br>\n".mysql_error();
		}
	}		


	public function getRow()
	{
		$result = mysql_fetch_array ($this->query_id); 
		echo mysql_error();
		return $result;
	}
	
	public function getNumRows()
	{
		return mysql_num_rows($this->query_id);
	}

	public function close()
	{
			mysql_close($this->db);
//			$this__destruct();
	}

}


?>